/**
 * 
 */
package implementations;

import interfaces.FlowElem;
import interfaces.GraphElement;

/**
 * @author Kai Bielenberg (kai.bielenberg@haw-hamburg.de)
 *
 */
public class FlowElemImpl  extends AbstractGraphElement implements FlowElem{

    private int flow;
    private final int capacity;
    
    private FlowElemImpl(int capacity, int flow) {
        this.flow = flow;
        this.capacity = capacity;
    }
    
    static FlowElemImpl valueOf(int capacity, int flow) {
        return new FlowElemImpl(capacity, flow);
    }

    @Override
    public int flow() {
        recordAccess();
        return this.flow;
    }

    @Override
    public int capacity() {
        recordAccess();
        return this.capacity;
    }

	@Override
	public void setFlow(int flow) {
	   
		if(flow>capacity || flow<0) throw new IllegalArgumentException();
		else 
		    this.flow=flow;
		
	}
	
	public String toString() {
	    return "(" + this.capacity() + "/" + this.flow() + ")";
	}
    
    

}
